home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!hpl3sn03.cern.ch
- From: Dan Pop <danpop@mail.cern.ch>
- Newsgroups: comp.lang.c
- Subject: Re: simple code, argc, argv, strcmp()
- Date: Fri, 2 Feb 1996 23:16:14 +0100
- Organization: CERN European Lab for Particle Physics
- Message-ID: <9602022216.AA20125@dxmint.cern.ch>
- References: <11f7cc$17261a.3b3@daprez> <4etj7c$bma@news.iag.net> <fcusack-0202961621470001@mudskipper.cac.psu.edu>
- X-NNTP-Posting-Host: hpl3sn03.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
- X-Mail2News-Path: dxmint.cern.ch!hpl3sn03.cern.ch
-
- fcusack@tdx.org (frank.) writes:
-
- >argv[1] is always guaranteed to exist. It is simply NULL if there were no
- >arguments.
-
- It may be always guaranteed on your platform, but the C language doesn't
- provide such a guarantee. The standard allows the situation when argc == 0,
- argv[0] == NULL and argv[1] doesn't exist at all.
-
- ANSI classic 2.1.2.2:
-
- If they are defined, the parameters to the main function shall obey
- the following constraints:
-
- * The value of argc shall be nonnegative.
-
- * argv[argc] shall be a null pointer.
-
- * If the value of argc is greater than zero, the array members
- argv[0] through argv[argc-1] inclusive shall contain pointers to
- strings, which are given implementation-defined values by the host
- environment prior to program startup. The intent is to supply to the
- program information determined prior to program startup from elsewhere
- in the hosted environment. If the host environment is not capable of
- supplying strings with letters in both upper-case and lower-case, the
- implementation shall ensure that the strings are received in
- lower-case.
-
- * If the value of argc is greater than zero, the string pointed to by
- argv[0] represents the program name ;argv[0][0] shall be the null
- character if the program name is not available from the host
- environment. If the value of argc is greater than one, the strings
- pointed to by argv[1] through argv[argc-1] represent the program
- parameters .
-
- * The parameters argc and argv and the strings pointed to by the argv
- array shall be modifiable by the program, and retain their last-stored
- values between program startup and program termination.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-